import React, { FC, memo } from 'react';
import styles from '@/components/auto-refresh-switch/autoRefreshSwitch.module.less';
import { Switch } from 'antd';

interface IBaseProps {
  text: string;
  checked: boolean;
  loading?: boolean;
  onChange: (flag: boolean) => void;
}

const Base: FC<IBaseProps> = (props) => {
  const { text, loading, onChange, checked } = props;
  return (
    <div className={`flex ai-center`}>
      <span className={styles.autoFreshText}>{text}</span>
      <Switch
        checked={checked}
        onChange={onChange}
        loading={loading ? loading : false}
      />
    </div>
  );
};

export default memo(Base);
